package edu.hm.swe2.junit;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

public class RationalTest {

	private Rational r;
	
	@Before
	public void setUp() {
		r = new Rational(1, 2);	
	}
	
	
	
	@Test
	public void testSetDenom() throws Exception {
		
		
		r.setDenom(3);
		
		Assert.assertEquals(3, r.getDenom());
		
		
		r.setDenom(-5);
		
		Assert.assertEquals(5, r.getDenom());
		Assert.assertEquals(-1, r.getNum());
		
	}

	@Test(expected=IllegalArgumentException.class)
	public void testSetDenom0() throws Exception {
		
    	r.setDenom(0);
		
	}
	
	@Test
	public void testExpandRational() throws Exception {
		
		r.expandRational(3);
		
		Assert.assertEquals(3, r.getNum());
		Assert.assertEquals(6, r.getDenom());
	
	}

	@Test(expected=IllegalArgumentException.class)
	public void testExpandRational0() throws Exception {
		
		r.expandRational(0);
	
	}

}
